
********************************************************************************
* Code for multinomial logit analyses in Goldfien "Just Patronage?" 
* 08/08/23 
********************************************************************************

**# SET UP 
clear all 

	// Set working directory and globals for your machine 
	cd "/Users//`c(username)'/Desktop/"
	global output "$directory/Output"
	
	//Load data 
	import delimited "amb_JCR.csv", clear
	
	//Confirm data set includes the expected 1,919 observations 
	count
	assert r(N) == 1919
	
**# CLEAN
	//Encode the ambassador type and president variables (i.e., convert variable type from string to numeric)
	*Ambassador type 
	encode type, gen(type_numeric)	
		//Recode and label the levels of the ambassador type variable   
		recode type_numeric (4 = 0)	(3 = 1) (2 = 2) (1 = 3) 
		label define type 0 "Low expertise, low familiarity" 1 "Low expertise, high familiarity" /// 
			2 "High expertise, low familiarity" 3 "High expertise, high familiarity"
		label val type_numeric type 
		label var type_numeric "Ambassador Type"
		
	*President 
	encode president, gen(pres_numeric)
	
		*Create a president variable by chronological (not alphabetical) order
		gen pres_chron = . 
		replace pres_chron = 1 if pres_numeric == 5
		replace pres_chron = 2 if pres_numeric == 1 
		replace pres_chron = 3 if pres_numeric == 3
		replace pres_chron = 4 if pres_numeric == 2
		replace pres_chron = 5 if pres_numeric == 4
		replace pres_chron = 6 if pres_numeric == 6
			//Label the presidents in this new chronological variable 
			label define pres 1 "Reagan" 2 "Bush, G.H.W." 3 "Clinton" 4 "Bush, G.W." 5 "Obama" 6 "Trump"
			label val pres_chron pres 
			label var pres_chron "Presidents (ordered chronologically)"
	
	//Destring other predictors used in multinomial logit models (i.e., convert variable type from string to numeric)
	foreach var in conflict_risk_rev log_gdppc hardship pop_wb /// 
		political_risk_rev tourism_share /// 
		high_high_political cinc trade { 
			replace `var' = "" if `var' == "NA"
			destring `var', replace 
}
		//Label predictors used in multinomial logit models 
		label var prior8 "POTUS Visits Last 8 Years"
		label var conflict_risk_rev "PRS Conflict Risk (0-24)"
		label var log_gdppc "Log GDP per Capita"
		label var hardship "DoS Hardship (0-35)"
		label var pop_wb "Population"
		label var alliance "Alliance"
		label var political_risk_rev "Political Risk"
		label var tourism_share "Tourism Share"
		label var high_high_political "High Difficulty, High Importance Post (Political)"
	

**# REGRESS: Fit multinomial logistic models, presenting results as relative risk ratios   
**# Table 4: Selection of Ambassador Expertise and Familiarity 
est clear 

eststo M1: mlogit type_numeric prior8 political_risk_rev i.pres_numeric, baseoutcome(0) vce(cluster ccode) rrr
eststo M2: mlogit type_numeric prior8 political_risk_rev log_gdppc i.pres_numeric, baseoutcome(0) vce(cluster ccode) rrr
eststo M3: mlogit type_numeric prior8 political_risk_rev hardship i.pres_numeric, baseoutcome(0) vce(cluster ccode) rrr
eststo M4: mlogit type_numeric prior8 political_risk_rev tourism_share i.pres_numeric, baseoutcome(0) vce(cluster ccode) rrr

esttab M1 M2 M3 M4 using "$output/Table4.tex", eform replace noomitted /// 
	indicate(POTUS Fixed Effects = *pres_numeric) /// 
	nogaps style(tex) label ///
		b(%9.2f) ci(%9.2f) star(+ 0.10 * 0.05 ** 0.01 *** 0.001) 
		
**# Appendix C.1
**# Table C.1: Predictors of Ambassador Expertise and Familiarity, Visits Prior 4 Years  
est clear 

eststo M1: mlogit type_numeric prior4 political_risk_rev i.pres_numeric, baseoutcome(0) vce(cluster ccode) rrr
eststo M2: mlogit type_numeric prior4 political_risk_rev log_gdppc i.pres_numeric, baseoutcome(0) vce(cluster ccode) rrr
eststo M3: mlogit type_numeric prior4 political_risk_rev hardship i.pres_numeric, baseoutcome(0) vce(cluster ccode) rrr
eststo M4: mlogit type_numeric prior4 political_risk_rev tourism_share i.pres_numeric, baseoutcome(0) vce(cluster ccode) rrr

esttab M1 M2 M3 M4 using "$output/TableC1.tex", eform replace noomitted /// 
	indicate(POTUS Fixed Effects = *pres_numeric) /// 
	nogaps style(tex) label ///
		b(%9.2f) ci(%9.2f) star(+ 0.10 * 0.05 ** 0.01 *** 0.001) 
		
**# Table C.2: Predictors of Ambassador Expertise and Familiarty, Population Importance Measure 
est clear 

eststo M1: mlogit type_numeric pop_wb political_risk_rev i.pres_numeric, baseoutcome(0) vce(cluster ccode) rrr
eststo M2: mlogit type_numeric pop_wb political_risk_rev log_gdppc i.pres_numeric, baseoutcome(0) vce(cluster ccode) rrr
eststo M3: mlogit type_numeric pop_wb political_risk_rev hardship i.pres_numeric, baseoutcome(0) vce(cluster ccode) rrr
eststo M4: mlogit type_numeric pop_wb political_risk_rev tourism_share i.pres_numeric, baseoutcome(0) vce(cluster ccode) rrr

esttab M1 M2 M3 M4 using "$output/TableC2.tex", eform replace noomitted /// 
	indicate(POTUS Fixed Effects = *pres_numeric) /// 
	nogaps style(tex) label ///
		b(%9.2f) ci(%9.2f) star(+ 0.10 * 0.05 ** 0.01 *** 0.001)	
		
**# Appendix C.2 
**# Table C.3: Predictors of Ambassador Expertise and Familiarity, Conflict Risk Difficulty Measure 
est clear 

eststo M1: mlogit type_numeric prior8 conflict_risk_rev i.pres_numeric, baseoutcome(0) vce(cluster ccode) rrr
eststo M2: mlogit type_numeric prior8 conflict_risk_rev log_gdppc i.pres_numeric, baseoutcome(0) vce(cluster ccode) rrr
eststo M3: mlogit type_numeric prior8 conflict_risk_rev hardship i.pres_numeric, baseoutcome(0) vce(cluster ccode) rrr
eststo M4: mlogit type_numeric prior8 conflict_risk_rev tourism_share i.pres_numeric, baseoutcome(0) vce(cluster ccode) rrr

esttab M1 M2 M3 M4 using "$output/TableC3.tex", eform replace noomitted /// 
	indicate(POTUS Fixed Effects = *pres_numeric) /// 
	nogaps style(tex) label ///
		b(%9.2f) ci(%9.2f) star(+ 0.10 * 0.05 ** 0.01 *** 0.001) 
		
**# Table C.4: Predictors of Ambassador Expertise and Familiarity, Alliance Difficulty Measure 
est clear 

eststo M1: mlogit type_numeric prior8 alliance i.pres_numeric, baseoutcome(0) vce(cluster ccode) rrr
eststo M2: mlogit type_numeric prior8 alliance log_gdppc i.pres_numeric, baseoutcome(0) vce(cluster ccode) rrr
eststo M3: mlogit type_numeric prior8 alliance hardship i.pres_numeric, baseoutcome(0) vce(cluster ccode) rrr
eststo M4: mlogit type_numeric prior8 alliance tourism_share i.pres_numeric, baseoutcome(0) vce(cluster ccode) rrr

esttab M1 M2 M3 M4 using "$output/TableC4.tex", eform replace noomitted /// 
	indicate(POTUS Fixed Effects = *pres_numeric) /// 
	nogaps style(tex) label ///
		b(%9.2f) ci(%9.2f) star(+ 0.10 * 0.05 ** 0.01 *** 0.001) 	

**# Appendix C.4
**# Table C.6: Appointments in High Difficulty, High Importance Posts 
est clear 

eststo M1: mlogit type_numeric high_high_political i.pres_numeric, baseoutcome(0) vce(cluster ccode) rrr
eststo M2: mlogit type_numeric high_high_political log_gdppc i.pres_numeric, baseoutcome(0) vce(cluster ccode) rrr
eststo M3: mlogit type_numeric high_high_political hardship i.pres_numeric, baseoutcome(0) vce(cluster ccode) rrr
eststo M4: mlogit type_numeric high_high_political tourism_share i.pres_numeric, baseoutcome(0) vce(cluster ccode) rrr
		
esttab M1 M2 M3 M4 using "$output/TableC6.tex", eform replace noomitted /// 
	indicate(POTUS Fixed Effects = *pres_numeric) /// 
	nogaps style(tex) label ///
		b(%9.2f) ci(%9.2f) star(+ 0.10 * 0.05 ** 0.01 *** 0.001) 		
				
**# Appendix C.6 
**# Table C.8: Ammbassador Selection by President 
est clear 

forvalues i = 1/6 {
	eststo: mlogit type_numeric prior8 political_risk_rev log_gdppc if pres_chron == `i', baseoutcome(0) vce(cluster ccode) rrr
}
esttab using "$output/TableC8.tex", eform replace noomitted /// 
	nogaps style(tex) label ///
		b(%9.2f) ci(%9.2f) star(+ 0.10 * 0.05 ** 0.01 *** 0.001) 

		
